using System;
using Amba.Workflow.Models;
using Orchard.Data.Migration;

namespace Amba.Workflow
{
    public class Migrations : DataMigrationImpl
    {
        public int Create()
        {
            SchemaBuilder.CreateTable(typeof(PeriodicalEventInfoRecord).Name,
                table => table
                    .Column<int>("Id", x => x.PrimaryKey().Identity())
                    .Column<DateTime>("LastRun")
                    .Column<int>("ActivityId")
                );
            SchemaBuilder.AlterTable(typeof (PeriodicalEventInfoRecord).Name,
                x => x.CreateIndex("eventID_idx", new[] {"ActivityId"}));
        
            SchemaBuilder.CreateTable(typeof(WorkflowLogRecord).Name,
                table => table
                    .Column<int>("Id", x => x.PrimaryKey().Identity())
                    .Column<int>("WorkflowId")
                    .Column<int>("ActivityId")
                    .Column<DateTime>("LogUtcDate")
                    .Column<string>("Title")
                    .Column<string>("LogMessage", x => x.Unlimited())
                );
            return 1;
        }
    }
}